package draw;

import edit.EditContext;

import java.awt.*;

import org.jbox2d.common.Vec2;

/**
 * @author will
 * @date Aug 9, 2008 9:32:19 PM
 */
public class DrawCircleSprite extends DrawSprite {

    public DrawCircleSprite(EditContext ed) {
        super(ed);
    }

    // Circle center = original mouse position, radius = distance
    protected void draw(Graphics2D g) {
        g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
        Vec2 currVec = ed.mousePos;

        // orig
        Vec2 curr = layer.getCanvasVector(currVec);
        Vec2 start = layer.getCanvasVector(startVec);

        Vec2 dist = start.sub(curr);
        float r = dist.length();
        Vec2 upleft = start.sub(new Vec2(r,r));
        Vec2 size = new Vec2(r*2,r*2);

//        Vec2 upleft = Vec2.min(curr,start);
//        Vec2 size = start.sub(curr).abs();
//        float r = Math.max(size.x,size.y);
        
        g.setColor(Color.green);
        g.drawOval(
                (int)upleft.x,(int)upleft.y,
                (int)size.x,(int)size.y);
    }
}
